import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: user
 * Date: 2024-04-04
 * Time: 16:21
 */
public class MyStack {
    public int[] elem;
    public  int usedSize;

    public MyStack() {
        this.elem = new int[10];
    }
    public void push(int val){
        if(isFull(elem)){
            expand(elem);
        }
        elem[usedSize] = val;
        usedSize++;
    }
    private boolean isFull(int[] elem){
        if(elem.length == usedSize){
            return true;
        }
        return false;
    }
    private void expand(int[] elem){
        elem = Arrays.copyOf(elem,2*elem.length);
    }
    public void stackDisplay(){
        for (int i = 0; i < usedSize; i++) {
            System.out.print(elem[i]+" ");
        }
    }
    public boolean isEmpty(){
        return usedSize == 0;
    }
    public int pop(){
        if(isEmpty()){
            return -1;
        }
        int ret = elem[usedSize-1];
        usedSize--;
        return  ret;
    }
    public int seek(){
        if(elem == null){
            return -1;
        }
        int ret = elem[usedSize-1];
        return  ret;

    }
    public int size(){
        return usedSize;
    }
}
